package com.czxy.mapper;

import com.czxy.pojo.Spu;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

/**
 * @author 张青卯
 */
@org.apache.ibatis.annotations.Mapper
public interface SpuMapper extends Mapper<Spu> {

    /**
     * findSpuBySpuId 查询品牌和分类
     * @param spuId 商品ID
     * @return Spu
     */
    @Select("select * from tb_spu where id = #{spuId}")
    @Results({
            @Result(property = "brand",column = "brand_id",
                one = @One(select = "com.czxy.mapper.BrandMapper.selectByPrimaryKey")),
            @Result(property = "cat3",column = "cat3_id",
                one = @One(select = "com.czxy.mapper.CategoryMapper.selectByPrimaryKey")),
    })
    Spu findSpuBySpuId(Integer spuId);

}